package com.gujh.security.util;

import cn.hutool.json.JSONUtil;
import com.gujh.security.model.Res;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.http.HttpStatus;

import java.io.IOException;

public class ResponseUtil {

    public static <DATA> void response(HttpServletResponse response, Res<DATA> res, HttpStatus httpStatus) throws IOException {
        response.setContentType("application/json;charset=UTF-8");
        response.setStatus(httpStatus.value());
        response.getWriter().write(JSONUtil.toJsonStr(res));
    }
}
